﻿package mortal.game.view.guild.cellrender
{
    import Message.Game.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guild.otherpanel.*;
    import mortal.mvc.core.*;

    public class GuildInviteListCellRenderer extends GuildCellRenderer
    {
        private var _txtGuildName:GTextFiled;
        private var _txtGuildMaster:GTextFiled;
        private var _txtGuildLevel:GTextFiled;
        private var _txtGuildMembers:GTextFiled;
        private var _btnAgree:GLoadedButton;
        private var _btnReject:GLoadedButton;
        private var _inviteData:SPlayerInviteInfo;

        public function GuildInviteListCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.align = "center";
            this._txtGuildName = UIFactory.gTextField("", 0, 3, 100, 20, this, _loc_1);
            this._txtGuildMaster = UIFactory.gTextField("xxxxxxx", 100, 3, 100, 20, this, _loc_1);
            this._txtGuildLevel = UIFactory.gTextField("25", 200, 3, 100, 20, this, _loc_1);
            this._txtGuildMembers = UIFactory.gTextField("25", 300, 3, 100, 20, this, _loc_1);
            this._btnAgree = UIFactory.gLoadedButton("GroupBtn_upSkin", 420, 1.5, 38, 22, this);
            this._btnAgree.label = Language.getString(60070);
            this._btnAgree.configEventListener(MouseEvent.CLICK, this.onMouseClick);
            this._btnReject = UIFactory.gLoadedButton("GroupBtn_upSkin", 460, 1.5, 38, 22, this);
            this._btnReject.label = Language.getString(60071);
            this._btnReject.configEventListener(MouseEvent.CLICK, this.onMouseClick);
            UIFactory.bg(0, 25, 530, 1, this, ImagesConst.SplitLine);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:* = param1 as SPlayerInviteInfo;
            this._inviteData = _loc_2;
            this._txtGuildName.text = _loc_2.guild.guildName;
            this._txtGuildMaster.htmlText = "<a href=\'event:guildmasterlink\' target = \'\'><font color=\'#ff9100\'><u>" + _loc_2.guild.leaderName + "</u></font></a>";
            this._txtGuildLevel.text = _loc_2.guild.level.toString();
            this._txtGuildMembers.text = _loc_2.guild.playerNum + "/" + _loc_2.guild.maxPlayerNum;
            return;
        }// end function

        protected function onMouseClick(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            switch(event.target)
            {
                case this._btnAgree:
                {
                    _loc_2 = new Object();
                    _loc_2.invitePlayerId = this._inviteData.inviter.entityId.id;
                    _loc_2.guildId = this._inviteData.guild.guildId;
                    _loc_2.agree = true;
                    _loc_2.type = EInviteMode._EInviteForJoinGuild;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GUILD_DEAL_INVITE, _loc_2));
                    break;
                }
                case this._btnReject:
                {
                    Cache.instance.guild.removeInviteInfo(this._inviteData.guild.guildId);
                    GuildInviteListPanel.instance.update();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
